package com.talos.ums.dal.mysql.usertenant;

import com.talos.framework.common.pojo.PageResult;
import com.talos.framework.mybatis.core.mapper.BaseMapperX;
import com.talos.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.talos.ums.controller.admin.usertenant.vo.UmsUserTenantPageReqVO;
import com.talos.ums.dal.dataobject.usertenant.UmsUserTenantDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 用户租户表 Mapper
 *
 * @author ${table.author}
 */
@Mapper
public interface UmsUserTenantMapper extends BaseMapperX<UmsUserTenantDO> {

    default PageResult<UmsUserTenantDO> selectPage(UmsUserTenantPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UmsUserTenantDO>()
                .eqIfPresent(UmsUserTenantDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UmsUserTenantDO::getTenantId, reqVO.getTenantId())
                .eqIfPresent(UmsUserTenantDO::getTenantCode, reqVO.getTenantCode())
                .likeIfPresent(UmsUserTenantDO::getTenantName, reqVO.getTenantName())
                .eqIfPresent(UmsUserTenantDO::getLeaseBeginAt, reqVO.getLeaseBeginAt())
                .eqIfPresent(UmsUserTenantDO::getLeaseEndAt, reqVO.getLeaseEndAt())
                .eqIfPresent(UmsUserTenantDO::getDisableFlag, reqVO.getDisableFlag())
                .betweenIfPresent(UmsUserTenantDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(UmsUserTenantDO::getModifyTime, reqVO.getModifyTime())
                .eqIfPresent(UmsUserTenantDO::getCreatorId, reqVO.getCreatorId())
                .eqIfPresent(UmsUserTenantDO::getCreatorCode, reqVO.getCreatorCode())
                .likeIfPresent(UmsUserTenantDO::getCreatorName, reqVO.getCreatorName())
                .eqIfPresent(UmsUserTenantDO::getModifierId, reqVO.getModifierId())
                .eqIfPresent(UmsUserTenantDO::getModifierCode, reqVO.getModifierCode())
                .likeIfPresent(UmsUserTenantDO::getModifierName, reqVO.getModifierName())
                .orderByDesc(UmsUserTenantDO::getId));
    }

}
